package com.example.togethermove.base;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.togethermove.R;
import com.example.togethermove.config.Constants;


/**

 **/

public class BaseActivity extends AppCompatActivity {


    protected TextView tv_headTitle, tv_headRight;
    protected ImageView iv_headLeft, iv_headRight;
    //完整的显示一个fragment
    public void startFragment(Class<? extends BaseFragment> fragmentClass, String title, Bundle bundle, boolean isShowActionbar, boolean isArrow) {
        Intent intent = new Intent(this, ShowActivity.class);
        //这个数据包给展示的fragment




        intent.putExtra(Fields.showActivity.bundle, bundle);

        //单独传递数据给activity
        intent.putExtra(Fields.showActivity.className, fragmentClass);
        intent.putExtra(Fields.showActivity.isShowActionbar, isShowActionbar);
        intent.putExtra(Fields.showActivity.title, title);
        intent.putExtra(Fields.showActivity.isArrow, isArrow);
        startActivity(intent);
    }



    protected void initHeader() {
        iv_headLeft = (ImageView) findViewById(R.id.iv_headLeft);
        tv_headTitle = (TextView) findViewById(R.id.tv_headTitle);
        iv_headRight = (ImageView) findViewById(R.id.iv_headRight);
        tv_headRight = (TextView) findViewById(R.id.tv_headRight);
    }
    public <T> void toNewActivity(Class<T> clazz) {
//        if (clazz == LoginByCaphaActivity.class) {
//            toNewActivity(ChooseLoginwayActivity.class);
//        } else {
//            startActivity(new Intent(this, clazz));
//        }
        startActivity(new Intent(this, clazz));
    }

    protected <T> void toNewActivity(Class<T> clazz, String data) {
        Intent it = new Intent(this, clazz);
        it.putExtra(Constants.intent_key_data, data);
        startActivity(it);
    }
    protected <T> void toNewActivity(Class<T> clazz, int data) {
        Intent it = new Intent(this, clazz);
        it.putExtra(Constants.intent_key_data, data);
        startActivity(it);
    }

    protected <T> void toNewActivity(Class<T> clazz, Bundle data) {
        Intent it = new Intent(this, clazz);
        it.putExtras(data);
        startActivity(it);
    }

}
